package com.steven.ourcontest.team.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.steven.ourcontest.base.BaseViewModel
import com.steven.ourcontest.team.api.TeamApi
import com.steven.ourcontest.team.bean.TeamApplyRes
import com.steven.ourcontest.utils.plusAssign

class TeamApplicationViewModel : BaseViewModel() {
    private val _teamApplicationResponse = MutableLiveData<TeamApplyRes>()
    val teamApplicationResponse: LiveData<TeamApplyRes>
        get() = _teamApplicationResponse

    fun updateApplyToTeam(applyId: Long, pass: Boolean,success:()->Unit) {
        disposed += TeamApi.instance.updateApplyToTeam(applyId, pass)
            .subscribe({
                success.invoke()
            }, {
                it.printStackTrace()
            })
    }

    fun queryApplyToMe() {
        disposed += TeamApi.instance.queryApplyToMe()
            .subscribe({
                _teamApplicationResponse.value = it
            }, {
                it.printStackTrace()
            })
    }
}